﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using HPT;
using System.Collections.Generic;

namespace News.WebParts.NewsDetailsWebPart
{
    public partial class NewsDetailsWebPartUserControl : OUserControl, IViewNewsDetails
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            presenterNewsDetails = new PresenterNewsDetails(this);
            if (!Page.IsPostBack)
            {
                presenterNewsDetails.GetNewsById();
            }
        }

        PresenterNewsDetails presenterNewsDetails;

        public NewsModal News
        {
            get
            {
                if (ViewState["News"] == null) ViewState["News"] = new NewsModal();
                return (NewsModal)ViewState["News"];
            }
            set
            {
                ViewState["News"] = value;
                SetNews();
            }
        }

        public new int ID
        {
            get { return qsID; }
        }

        private void SetNews()
        {
            if (News != null) 
                ltrContents.Text = News.Title + News.Contents;
        }
    }
}
